<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button onclick="getAll()">获取所有文章</button>
    <button onclick="getById()">根据id获取文章详情</button>
    <button onclick="deleteById()">根据id删除文章</button>
    <button onclick="patchById() ">根据id修改文章</button>
    <button onclick="post()">发布文章</button>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.js"></script>
    <script>
        let articlesAPI = 'http://localhost:3000/articles';

        async function getAll() {
            let r = await axios.get(articlesAPI, { params: { pagenum: 1, pagesize: 10 } })
            console.log(r.data);
        }

        async function getById() {
            let r = await axios.get(articlesAPI + '/1')
            console.log(r.data);
        }

        async function deleteById() {
            let r = await axios.delete(articlesAPI + '/1')
            console.log(r.data);
        }
        async function patchById() {
            let r = await axios.patch(articlesAPI + '/1', { title: 'aaa', content: 'abb' })
            console.log(r.data);
        }
        async function post() {
            let r = await axios.post(articlesAPI, { title: 'aaa', content: 'abb' })
            console.log(r.data);
        }

    </script>

</body>

</html>